package com.voda.web.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.voda.entity.Role;
import com.voda.service.api.IRoleService;
import com.voda.web.common.AbstractMappingController;
import com.voda.web.util.ResponseMapUtil;

/**
 * The Class RoleController.
 */
@Controller
@RequestMapping(value = "/cms/roles")
public class RoleController extends AbstractMappingController {
	
	private static final String ERROR_GET_ROLES = "error";

	private static final String SUCCESS_GET_ROLES = "success";
	
	/** The role service. */
	@Autowired
	private  IRoleService roleService;
	
	/**
	 * Gets the users list.
	 *
	 * @return the users list
	 */
	@RequestMapping(method = RequestMethod.GET)
	public @ResponseBody Map<Object, Object> getRolesList() {
		try {
			List<Role> result = roleService.getAll();
			return ResponseMapUtil.mapSuccess(result, resourceBundleUtil.getMessage(SUCCESS_GET_ROLES));
		} catch (Exception e) {
			return ResponseMapUtil.mapError(resourceBundleUtil.getMessage(ERROR_GET_ROLES));
		}
	}

}
